<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="UTF-8">
	<title>box</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" id="viewport" />
	<link rel="stylesheet" href="css/demo.css" type="text/css" />
	<link rel="stylesheet" type="text/css" href="css/sweet-alert.css">
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<link rel="stylesheet" type="text/css" href="css/index-red.css">
	
	<style type="text/css">

	</style>
	<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript">
			localStorage.userToken = "${userId}";
			$(document).ready(function() {
				var win = (parseInt($(".couten").css("width"))) - 60;
				$(".mo").css("height", $(document).height());
				$(".couten").css("height", $(document).height());
				$(".backward").css("height", $(document).height());
				$("li").css({});
				var add = function() {
					var hb = parseInt(Math.random() * (3 - 1) + 1);
					var Wh = parseInt(Math.random() * (70 - 30) + 30);
					var Left = parseInt(Math.random() * (win - 0) + 0);
					var rot = (parseInt(Math.random() * (45 - (-45)) - 45)) + "deg";
					num--;
					if (num>0) {
						$(".couten").append("<li class='li" + num + "' ><a href='javascript:;'><img src='images/hb_" + hb + ".png'></a></li>");
					$(".li" + num).css({
						"left": Left,

					});
					$(".li" + num + " a img").css({
						"width": Wh,
						"transform": "rotate(" + rot + ")",
						"-webkit-transform": "rotate(" + rot + ")",
						"-ms-transform": "rotate(" + rot + ")", /* Internet Explorer */
						"-moz-transform": "rotate(" + rot + ")", /* Firefox */
						"-webkit-transform": "rotate(" + rot + ")",/* Safari 和 Chrome */
						"-o-transform": "rotate(" + rot + ")" /* Opera */
					});	
					$(".li" + num).animate({'top':$(window).height()+20},5000,function(){
						this.remove()
					});
					$(".rob > input").click(function(){
						$(".mo").css({
							display: 'block'
						});
						$(this).attr({
							disabled: 'true'
						});
						$(this).css({
							backgroundImage: 'url(images/rob-bg-1.png)'
						});
					});
					$(".close-btn").click(function(){
						$(".mo").css({
							display: 'none'
						});
					});
					setTimeout(add,200)
					};
				}	
				
				var num = 100;
				setTimeout(add,000);
				
				

		
			})
			function robHb()
			{
			   $.ajax({
	    		type : "POST",
				dataType : "text",
				url : "redpacketc/takeHb",
				data : "userId=" + localStorage.userToken,
				success : function(data){
					var jsonPageAndList = $.parseJSON(data);
					if(jsonPageAndList.resultcode==0)
					{
					  var html="";
					  html='<strong>'+jsonPageAndList.money+'</strong><span>元</span>';
					  $(".softword").html(html);
					  
					}
					else if(jsonPageAndList.resultcode==1)
					{
						$(".softword").addClass("pro");
					  $(".softword").html("您不已经领过了？贪多不是好孩子~");
					}
					else if(jsonPageAndList.resultcode==2)
					{
						$(".softword").addClass("pro");
					  $(".softword").html("您怎么不早点来？黄花菜都被抢光了！");
					}
					else if(jsonPageAndList.resultcode==3)
					{
					  $(".softword").addClass("pro");
 					  $(".softword").html("帐号瓦特啦！重登客户端吧~");
					}
					else
					{
						$(".softword").addClass("pro");
					  $(".softword").html("网络君睡着了，快点叫醒它吧~");
					}
				}
			})
			}
		</script>

  </head>
  
  <body>
    <section>
		<div>
			<ul class="couten"></ul>
		</div>
	</section>
	<section class="money1">
		<div class="mo">
			<div class="sen">
				<div class="softword"><strong id="money"></strong><span></span></div>
				<button class="close-btn" >确定</button>
			</div>
		</div>
	</section>
	<section class="rob">
		<input  type="button" class=""  onclick="robHb()">
	</section>
<!-- 	<section class="prom"> -->
<!-- 		<div id="tip">您怎么不早点来？黄花菜都被领完了！</div> -->
<!-- 	</section> -->
  </body>
</html>
